<?php
	header("content-type:text/html;charset=utf-8");
	require_once 'lib/smarty/smarty.class.php';
	session_start();
	$smarty=new Smarty();
	$mysqli = mysqli_connect("localhost","root","","aaa");
	if(isset($_FILES['file'])){
		$file=$_FILES['file'];
		$point=strrpos($file['name'],".");
		$ext=substr($file['name'],$point);
		$filename=time().$ext;
		$path='files/'.$filename;
		$re=move_uploaded_file($file['tmp_name'],$path);
		if($re){
			$sql="insert into file(name,uper) values ('".$filename."','".$_SESSION['aa_user']['id']."')";
			$line = $mysqli->query($sql);
			echo "上传成功";
		}else{
			echo '上传失败';
		}
	}else{
		
		//var_dump($_SESSION['aa_user']);
		$smarty->display('file.html');
	}